package com.xcoder.leetcode;

/**
 * https://leetcode-cn.com/problems/climbing-stairs/
 */
public class _70_爬楼梯 {

    public static void main(String[] args) {
        System.out.println(climbStairs(5));
    }

    private static int climbStairs(int n) {
        if (n <= 2) {
            return n;
        }
        int a = 1, b = 2, s = 0;
        for (int i = 3; i <= n; i++) {
            s = a + b;
            a = b;
            b = s;
        }
        return s;
    }
}
